
 class MyGrid extends egret.Shape{
    public constructor(){
        super();
        this.createGird(50,50,9,9);
    }
    //创建格子函数，根据输入的宽和高来创建一个 row * line的格子图。并返回Shape对象。
    private createGird(w:number,h:number,row:number,line:number):void {
        // var shape:egret.Shape = new egret.Shape();
        for(var i = 0;i < row;i++ ) {
            for(var j = 0; j < line;j++) {
                if ((j + row * i) % 2 === 0) {
                    this.graphics.beginFill(0xF9C20B);
                    this.graphics.drawRect(j * w, i * h, w, h);
                    this.graphics.endFill();
                }
                else {
                    this.graphics.beginFill(0x2A9FFF);
                    this.graphics.drawRect(j * w, i * h, w, h);
                    this.graphics.endFill();
               }
            }
        }
        // return shape;
    }
}
